window.onload = async function() {
    const list = await apiGetProducts();
    const container = document.getElementById('productList');
    if (list.length === 0) {
        container.innerHTML = '暂无商品';
        return;
    }
    container.innerHTML = list.map(p => `
    <div class="product-item">
      <a href="/product.html?id=${p.id}">
        <img src="${p.coverImage || '/default.jpg'}" alt="图片" style="width:100px;height:100px;">
        <div>${p.title}</div>
        <div>￥${p.price}</div>
      </a>
    </div>
  `).join('');
};
